package com.jingding.procurement.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;

import java.util.HashMap;
import java.util.Map;

//发送http请求测试
@Slf4j
public class Main {
    /*get请求测试*/
    public static void maincs(String[] args) {
        JSONObject jsonObject = Requesting.httpGet("http://localhost:9999/dog/select?id=0");
        Map<String, Object> listMap = new HashMap<>();
       for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
            listMap.put(entry.getKey(), entry.getValue());
        }
        System.out.println(listMap.toString());

        JSONObject jsonData = jsonObject.getJSONObject("data");
        Map<String, Object> dataMap = new HashMap<>();
    /*    try {
            for (Map.Entry<String,Object> s : jsonData.entrySet()){
                dataMap.put(s.getKey(),s.getValue());
            }
        }catch (NullPointerException e){
            System.out.println("查询到的数据为空");
        }
*/
        System.out.println(dataMap);
        //TextNew textNew = JSON.toJavaObject(jsonData, TextNew.class);
        // System.out.println(textNew);

    }

    //post请求测试
    public static void main(String[] args) {
//        TextNew textNew = new TextNew();
//        textNew.setAge(1);
//        textNew.setAssortment("香蕉哦");
//        textNew.setName("王培超");
//        textNew.setColor("黑色");
//        String s = Requesting.httpPost("http://localhost:9999/dog/insert", JSON.toJSONString(textNew));
//        JSONObject jsonObject = JSON.parseObject(s);
//        Return aReturn = JSON.toJavaObject(jsonObject, Return.class);
//
//        System.out.println(aReturn);

    }
}
